<?php
function smarty_function_country_regions($params, &$smarty){
	$oRegions = new Models_Locations_Regions();
	
	$regions = $oRegions->getRegionsByCountry($params['country']);
	
	$output = "<select name='".$params['name']."' id='".$params['name']."_id' size='1'>\n";
	foreach($regions as $region){
		
		if($region->country_region_id == $params['value']){
			$selected="selected='selected'";
		}else{
			$selected="";
		}
		
		$output.="<option value='".$region->country_region_id."' $selected>".$region->country_region_name."</option>\n";
	}	
	$output.='</select>';
	
	echo $output;
}